package com.crape.common.thread;

import org.apache.log4j.Logger;

import com.crape.common.mail.EmailSentParam;
import com.crape.common.mail.EmailService;

public class EmailThread implements Runnable {

    protected final Logger log = Logger.getLogger(this.getClass());

    private EmailService   emailService;
    private EmailSentParam emailSentParam;

    public EmailThread(EmailService emailService, EmailSentParam emailSentParam){
        this.emailSentParam = emailSentParam;
        this.emailService = emailService;
    }

    @Override
    public void run() {
        try {
            emailService.sendEmail(emailSentParam.getModel(), emailSentParam.getSubject(), emailSentParam.getVmPath(),
                                   emailSentParam.getEmail(), emailSentParam.getAttachment(),
                                   emailSentParam.getCcEmail());
        } catch (Exception e) {
            log.error("emal thread run error", e);
        }
    }

}
